//学科评估
<template>
  <div class="module_">
    <div class="mb8">
      <search @clearSearch='clearSearch'>
        <el-form label-width='80px' inline autocomplete="off" :model="pageparm" class="search_box">
          <el-form-item label="学科" v-if="adminShow">
            <inputSearch type="xueke" ref="search_d" @onChange='searchChane($event,"discipline_id")'  />
          </el-form-item>
          <el-form-item label="评估年度">
            <el-date-picker size="medium" v-model="pageparm.year" type="year" format="yyyy" value-format="yyyy"
              @change="searchChane($event,'year')" placeholder="请选择年份搜索">
            </el-date-picker>
          </el-form-item>
        </el-form>
        <template slot="footer">

        </template>
      </search>
    </div>
    <el-table :data="tableData" class="flex-1" height="100%" size="medium" border highlight-current-row
      v-loading="tableLoading" stripe @sort-change="tableSortChange">
      <el-table-column align="center" show-overflow-tooltip prop="name" label="学科" width="220" sortable="custom">
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip prop="year" label="年度" width="120" sortable="custom">
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip prop="score" label="总分" width="150" sortable="custom">
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip prop="rank" label="排名" width="120" sortable="custom">
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip prop="bonus" label="奖励(万元)" width="150" sortable="custom">
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip prop="bonus_balance" label="奖励余额(万元)" width="160" sortable="custom">
      </el-table-column>
      <el-table-column align="center" label="经费管理" width="120">
        <div slot-scope="scope" class="tx-c">
          <el-tooltip effect="dark" content="经费管理" placement="bottom-end">
            <el-button size="small" @click="goStart(scope.row)" circle>
              <i class="iconfont icon-jurassic_mge-money"></i>
            </el-button>
          </el-tooltip>
        </div>
      </el-table-column>
    </el-table>

    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
  </div>
</template>

<script>
  import {Apievaluaterank}  from '@/api'
  import {debounce,adminShow,} from "@/utils/index";
  export default {
    name: 'disciplineFunds',
    data() {
      return {
        adminShow: adminShow(),
        tableData: [],
        editFormVisible: false,
        editForm: {}, //修改或者查看详情
        pageparm: {
          page: 1,
          perPage: 20,
          total: null,
          sort_str: null,
          sort_order: 'asc',
        },
        tableLoading: false,

        btnLoading: false,

        dialogTitle: '',

        pickerOptions: {
          disabledDate: (time) => {
            return time.getTime() < Date.now() - 86400000;
          }
        }
      }
    },
    activated() {
      if(sessionStorage.getItem('disciplineFunds')){
        sessionStorage.removeItem('disciplineFunds')
      }else{
        this.pageparm.page = 1
      }
      this.getList()
    },
    methods: {
      goStart(value) {
        sessionStorage.setItem('disciplineFunds',1234)
        this.$router.push('/subject/fundsManagement?id='+value.id)
      },
      tableSortChange(column) {
        if (column.order === "descending") {
          this.pageparm.sort_str = column.prop;
          this.pageparm.sort_order = "desc";
        } else if (column.order === "ascending") {
          this.pageparm.sort_str = column.prop;
          this.pageparm.sort_order = "asc";
        } else {
          this.pageparm.sort_str = null;
          this.pageparm.sort_order = null;
        }
        this.getList()
      },
      //搜索
      clearSearch() {
        if(this.$refs.search_d) this.$refs.search_d.clear()
      },
      searchChane(i, val) {
        this.pageparm[val] = i
        this.pageparm.page = 1
        this.getList()
      },
      //分页
      callFather(pageparm) {
        this.pageparm.page = pageparm.page
        this.pageparm.perPage = pageparm.perPage
        this.getList()
      },
      getList() {
        this.tableLoading = true
        Apievaluaterank(this.pageparm).then(({data,page}) => {
          this.tableData = data || []
          this.pageparm.total = page.total
          this.tableLoading = false
          this.$set(this.pageparm,'year',data[0].year)
        }).catch(() => {
          this.tableLoading = false
        })
      },
      dialogClose() {
      },
    },

  }
</script>